package com.youlv.yl.api;

import com.youlv.yl.manager.intf.OssService;
import com.youlv.yl.vo.R;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author fenghe
 * @date 2022/1/12 19:37
 */
@RestController
@RequestMapping("/api/oss")
@Api(value = "实现资源的相关操作", tags = "实现资源的相关操作")
/**跨域*/
@CrossOrigin
public class AliOssController {

    @Autowired
    private OssService service;

    /** 单张图片的上传*/
    @PostMapping("imgUpload.do")
    public R uploadFile(@RequestPart MultipartFile file) {
        return service.upload(file);
    }

    /** 多张图片的上传*/
    @PostMapping("imgsUpload.do")
    public R uploadFiles(@RequestPart MultipartFile[] files) {
        for (MultipartFile file : files) {
            System.out.println(file);
        }
        return service.updateMore(files);
    }
}
